<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');


/**
 * 生成缩略名
 *
 * @access public
 * @param string $str 需要生成缩略名的字符串
 * @param string $default 默认的缩略名
 * @param integer $maxLength 缩略名最大长度
 * @return string
 */
if( ! function_exists('slugName'))
{
    function slugName($str, $default = NULL, $maxLength = 200)
    {
        $str = str_replace(array("'", ":", "\\", "/", '"'), "", $str);
        $str = str_replace(array("+", ",", ' ', '，', ' ', ".", "?", "=", "&", "!", "<", ">", "(", ")", "[", "]", "{", "}"), "-", $str);
        $str = trim($str, '-');
        $str = empty($str) ? $default : $str;
//self::$charset
        return function_exists('mb_get_info') ? mb_strimwidth($str, 0, 128, '', 'utf-8') : substr($str, 0, $maxLength);
    }
}